package net.nampham.visioncontrol.view;

import java.nio.FloatBuffer;

import net.nampham.visioncontrol.Logger;

import android.opengl.GLES20;
import android.util.Log;

public class RObject {
	IMaterial mat;
	FloatBuffer vertices;
	int primitive_type;
	int primitive_count = -1;//-1 means draw all

	void initialze(){
		mat.initialize_once();
	}
	
	void render(){
		mat.initialize_specific(vertices);
		if (primitive_count==-1)
			GLES20.glDrawArrays(primitive_type, 0, vertices.capacity()/mat.getVertexStride());
		else{
			if (primitive_type==GLES20.GL_LINES){
				GLES20.glDrawArrays(primitive_type, 0, primitive_count*2);
			}
			else if (primitive_type==GLES20.GL_TRIANGLES){
				GLES20.glDrawArrays(primitive_type, 0, primitive_count*3);
			}else{
				Logger.e("not yet implemented");
			}
			//Logger.d("DrawArray:"+String.valueOf(primitive_count));
		}		
	}
	
	void dispose(){
		
	}
}
